package com.ailot.cloud.upms.api.controller;


import com.ailot.cloud.base.log.event.entity.SysLog;
import com.ailot.cloud.upms.api.service.SysLogService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 日志
 */
@RestController
@AllArgsConstructor
@RequestMapping("/log")
public class SysLogController {
    private final SysLogService sysLogService;

    @GetMapping("/page")
    @PreAuthorize("hasAuthority('sys:log:page')")
    public Page<SysLog> pageLog(Page<SysLog> page, SysLog sysLogInfo) {
        return sysLogService.page(page, Wrappers.query(sysLogInfo));
    }


    /**
     * 插入日志
     */
    @PostMapping()
    public Boolean add(@Valid @RequestBody SysLog sysLogInfo) {
        return sysLogService.save(sysLogInfo);
    }

}
